package com.yunhe.policyfulfillment.authority.controller;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.model.mybatis.PageResult;
import com.yunhe.policyfulfillment.authority.domain.PolicyCompanyRegistration;
import com.yunhe.policyfulfillment.authority.model.AuditPolicyCompanyRegistration;
import com.yunhe.policyfulfillment.authority.model.PolicyCompanyRegistrationQueryCondition;
import com.yunhe.policyfulfillment.authority.service.PolicyCompanyRegistrationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunhe.common.model.ResultObject;

import java.util.List;

/**
 * @description 企业注册表
 * @author misty
 * @date 2021-09-18
 */
@Api(value = "PolicyCompanyRegistration", description = "企业注册表维护", tags = {"Model_PolicyCompanyRegistration"})
@RestController
@RequestMapping(value = "/policyCompanyRegistration")
public class PolicyCompanyRegistrationController {

    @Autowired
    private PolicyCompanyRegistrationService policyCompanyRegistrationService;


    /**
     * 刪除
     * @author misty
     * @date 2021/09/18
     **/
    @ApiOperation("根据id删除企业注册表")
    @DeleteMapping("/deletePolicyCompanyRegistration")
    public ResponseEntity<ResultObject> deletePolicyCompanyRegistration(@RequestParam(value = "id",required = true) Long id){
        policyCompanyRegistrationService.deletePolicyCompanyRegistration(id);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("查询企业注册列表")
    @PostMapping("/findPolicyCompanyRegistrationByCondition")
    public ResponseEntity<ResultObject<List<PolicyCompanyRegistration>>> findPolicyCompanyRegistrationByCondition(@RequestBody PolicyCompanyRegistrationQueryCondition policyCompanyRegistrationQueryCondition){
        PageResult pageResult = policyCompanyRegistrationService.findPolicyCompanyRegistrationByCondition(policyCompanyRegistrationQueryCondition);
        return new ResponseEntity(new ResultObject<>(pageResult), HttpStatus.OK);
    }

    /**
     * 审核企业注册信息
     * @author misty
     * @date 2021/09/18
     **/
    @ApiOperation("审核企业注册信息")
    @PostMapping("/auditPolicyCompanyRegistration")
    public ResponseEntity<ResultObject> auditPolicyCompanyRegistration(@RequestBody AuditPolicyCompanyRegistration auditPolicyCompanyRegistration) throws ArgumentErrorException, ObjectNotFoundException {
        policyCompanyRegistrationService.auditPolicyCompanyRegistration(auditPolicyCompanyRegistration);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    /**
     * 查询 根据主键 id 查询
     * @author misty
     * @date 2021/09/18
     **/
    @ApiOperation("根据id查询企业注册表")
    @GetMapping("/findPolicyCompanyRegistrationById")
    public ResponseEntity<ResultObject<PolicyCompanyRegistration>> findPolicyCompanyRegistrationById(@RequestParam(value = "id",required = true) Long id){
        return new ResponseEntity<>(new ResultObject(policyCompanyRegistrationService.findPolicyCompanyRegistrationById(id)),HttpStatus.OK);
    }

}